package by.yativem.commons.beans;

import java.lang.reflect.Method;

public class Beans {
	
	public static Method getSetMethod(String propName,  Class<?> cl ){
		Method m = null;
		String mName = buildSetName (propName);
		for(Method mt: cl.getMethods() ){
			if( mt.getName().equals(mName) && mt.getParameterTypes().length == 1 &&  mt.getParameterTypes()[0] == String.class){
				m = mt;
				break;
			}
		}
		return m;
	}
	
	protected static String buildSetName(String prop){
		
		String result = "set" +  prop.substring(0, 1).toUpperCase() + prop.substring(1);
		return result;
	}

}
